package com.smiier.skin.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import cn.o.app.ui.OStateView;
import cn.skinapp.R;

import com.evan.common.utils.CommonUtility;
import com.smiier.skin.utils.DBUtil;

public class BasicStateView extends OStateView {

	protected TextView back, text_nav, text_right;
	
	protected ProgressBar progress;

	protected DBUtil dbUtil;

	public BasicStateView(Context context) {
		super(context);
	}

	public BasicStateView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public BasicStateView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public void onCreate() {
		super.onCreate();
		dbUtil = DBUtil.getInstance(getContext());
	}

	protected void init() {
		back = (TextView) findViewById(R.id.btn_left);
		text_nav = (TextView) findViewById(R.id.text_nav);
		text_right = (TextView) findViewById(R.id.text_right);
		progress = (ProgressBar) findViewById(R.id.progress_bar);
	}

	protected void setNavTitle(String title) {
		if (!CommonUtility.isNull(text_nav)) {
			text_nav.setText(title);
		}
	}

	protected void setNavLeftBtn(String title) {
		if (!CommonUtility.isNull(back)) {
			back.setText(title);
		}
	}

	protected void setNavLeftBtnNoDrawable() {
		if (!CommonUtility.isNull(back)) {
			back.setCompoundDrawables(null, null, null, null);
		}
	}

	protected void setNavRightBtn(String title) {
		if (!CommonUtility.isNull(text_right)) {
			text_right.setVisibility(View.VISIBLE);
			text_right.setText(title);
		}
	}

	protected void setNavRightBtnDrawable(int resid) {
		if (!CommonUtility.isNull(text_right)) {
			text_right.setVisibility(View.VISIBLE);
			text_right.setBackgroundResource(resid);
		}
	}

	protected void setNavRightBtnIcon(int resid) {
		if (!CommonUtility.isNull(text_right)) {
			text_right.setVisibility(View.VISIBLE);
			text_right.setCompoundDrawablesWithIntrinsicBounds(null, null, this
					.getResources().getDrawable(resid), null);
		}
	}

}
